Warn when unpinned recipe artifacts resolve from Maven Central - #1181
Open
timtebeek wants to merge 3 commits into
Open
Warn when unpinned recipe artifacts resolve from Maven Central#1181timtebeek wants to merge 3 commits into
timtebeek wants to merge 3 commits into
Conversation
Recipe artifacts are now published to the Code Genome Project, so the releases left behind on Maven Central go stale. Users without a CGP repository configured still resolve successfully against Maven Central and silently stop picking up newer recipe versions. When a `rewrite.recipeArtifactCoordinates` entry with an unpinned version (`LATEST`, `RELEASE`, or a range) in an `org.openrewrite` or `io.moderne` group resolves from the real Maven Central, log an informational warning pointing at the docs for configuring a download token. Resolution is never blocked, and no warning is emitted for pinned versions or for artifacts served by a configured repository or internal mirror. Fixes #1180
Match the Gradle plugin's naming, message text, and credentials link so both plugins report the same thing: - CodeGenomeProjectWarning.warningFor(..), CREDENTIALS_DOCS - the same multi-line message listing every stale recipe artifact - https://codegenomeproject.org/token instead of the docs quickstart - the same Maven Central host set and recipe group check Maven-specific: each line is logged separately, since Maven only prefixes the first line of a multi-line message with [WARNING]. The listed coordinate also carries the version it resolved to, which Maven knows and Gradle does not. StaleRecipeArtifactIT mirrors the Gradle StaleRecipeArtifactTest.
timtebeek
marked this pull request as ready for review
July 29, 2026 10:42
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
When
rewrite.recipeArtifactCoordinatesasks for an OpenRewrite/Moderne recipe artifact with a dynamic version (LATEST,RELEASE,[6.0,7.0), …) and it is served by the real Maven Central, the plugin logs a warning pointing at the Code Genome Project:Informational only — resolution is untouched and the build still succeeds.
Acceptance criteria
repo.maven.apache.org/repo1.maven.org/repo2.maven.orgcount as Maven Central. Maven substitutes a mirror's id and URL into the project's repositories before resolution, so a mirror is reported under its own URLAlignment with the Gradle plugin
Shared with openrewrite/rewrite-gradle-plugin#459: the
CodeGenomeProjectWarningclass name, thewarningFor(..)entry point returning@Nullable String, theCREDENTIALS_DOCSconstant, the exact message text, the Maven Central host set, and theorg.openrewrite/io.modernegroup check.CodeGenomeProjectWarningTestandStaleRecipeArtifactITmirror the Gradle plugin'sCodeGenomeProjectWarningTestandStaleRecipeArtifactTestcase for case.Three deliberate divergences:
ResolutionResultexposes no repository origin, so it falls back to inspecting declared repositories. Maven'sArtifactResult.getRepository()reports the serving repository — and, thanks to the enhanced local repository manager's_remote.repositoriestracking, still does so for artifacts already in the local cache. That's strictly more precise, so I kept it.…:LATEST resolved to 3.42.1). Maven knows this at warning time; Gradle does not.The dynamic-version selectors necessarily differ, since each matches its own build tool's syntax:
LATEST/RELEASE/[/(here versuslatest.*/+/ranges in Gradle.Design notes / open questions
rewrite.recipeArtifactCoordinates, which is what this plugin resolves itself. Recipe modules declared as plugin<dependencies>are resolved by Maven core before the mojo runs and are always pinned, so they fall outside both the hook point and the acceptance criteria. This matches the Gradle PR leaving the plugin's own bundled dependencies unchecked.ArtifactResolver's constructor gained aLogparameter. Both call sites are in this repo.Testing
CodeGenomeProjectWarningTest— 12 cases over the detection rule (dynamic selectors, Moderne groups, pinned versions, unrelated groups, internal mirror, CGP-served, transitive dependencies, non-remote repository).StaleRecipeArtifactIT— itf integration tests asserting the warning appears onrewrite:discoverfor aLATESTcoordinate and stays quiet for a pinned one. Both pass locally (~16s).<mirror>ofcentralconfigured, Maven reports the project's remote repositories as the mirror's id/URL, so the host check cannot match.